/*
 * @Descripttion:
 * @version:
 * @Author: MichaelHu
 * @Date: 2020-08-28 16:08:41
 * @LastEditors: MichaelHu
 * @LastEditTime: 2022-11-25 21:16:42
 */
#include "at32f4xx.h"
#include "delay.h"
#include "easyflash.h"
#include "sfud.h"
#include "st7789.h"
#include "sys.h"
#include "usart.h"

extern void MX_FREERTOS_Init(void);

int main(void)
{
#if defined IAP
    SCB->VTOR = FLASH_BASE | 0x3000;
#endif

    u16 t = 0;
    const sfud_flash *flash = sfud_get_device_table() + 0;
    enum PLLClkSrc ClkSrc = PLL_HSI;
    SysclkConfig(ClkSrc, 120);
    delay_init(120);
    usart_dma_init(921600, FIFO_BUF_LENGTH);
    /* SFUD initialize */
    if (sfud_init() == SFUD_SUCCESS)
    {
    }
    MX_FREERTOS_Init();
    for (;;)
    {
    }
}

#ifdef USE_FULL_ASSERT
/**
 * @brief  Reports the name of the source file and the source line number
 *         where the assert_param error has occurred.
 * @param  file: pointer to the source file name
 * @param  line: assert_param error line source number
 * @retval None
 */
void assert_failed(uint8_t *file, uint32_t line)
{
    /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

    /* Infinite loop */
    while (1)
    {
    }
}
#endif
